//
// Created by francklinson on 2021/10/21 AT 10:57.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>

using namespace std;

class Solution {
public:
    bool isPrefixString(string s, vector<string> &words) {
        int n = s.size();
        string cur;
        // 将数组中的字符进行拼接 当长度和s相等时，判断和s是否相同
        for (auto &word: words) {
            n -= word.size();
            cur += word;
            if (n == 0) {
                return cur == s;
            }
            if (n < 0)
                return false;
        }
        return false;
    }
};

int main() {
    string s("iloveleetcode");
    vector<string> words{"i", "love", "leetcode", "apples"};
    Solution solution;
    cout << solution.isPrefixString(s, words) << endl;
    return 0;
}

